﻿using Mirror;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class FeatureSlot : Slot
{
    //public float EffectRange = 10;
    //public float EffectAngle = 10;

    public Feature Feature { get { return m_Feature; } }
    Feature m_Feature;
    void Start()
    {
        switch(Size)
        {
            case SlotSize.WEAPON_SIZE_SMALL:
                m_Feature = new Shild();
                break;
            case SlotSize.WEAPON_SIZE_MIDDLE:
                m_Feature = new ShildMiddle();
                break;
            case SlotSize.WEAPON_SIZE_BIG:
                m_Feature = new ShildBig();
                break;
        }

        switchFeature(m_Feature);
        m_Feature.SetSlot(this);
    }

    protected override void Update()
    {
        base.Update();
        m_Feature.update();
    }
    public void fire()
    {
        if (null == m_Feature)
            return;
        m_Feature.fire();

    }
    public void switchFeature(Feature feature)
    {
        if (null != m_Feature)
            m_Feature.unload(this);
        if (feature == null)
            return;

        m_Feature = feature;
        EmiterObject = Instantiate(Resources.Load<GameObject>(m_Feature.EmiterResource)) as GameObject;
        EmiterObject.transform.SetParent(transform, false);
        m_Feature.load(this);

        if(m_Ship)
        {
            m_Feature.m_Influence = m_Ship.m_ShipStruct.m_Influence;
        }
    }
}
